﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Data;
using System.Windows.Resources;
using System.ComponentModel;
using VIBlend.WPF.Controls;
using System.Reflection;
using System.Data;
using AnonsaiWPF.NwindDataSetTableAdapters;

namespace AnonsaiWPF.CSharp.DataGridViewDemos
{
    [Category("VIBlend.WPF.Examples")]
    public partial class PivotTableDemo : Window, IWindow
    {
        #region IWindow Members

        public void DetachContent()
        {
            RemoveLogicalChild(Content);
        }

        public Grid Root
        {
            get
            {
                return this.LayoutRoot;
            }
        }
        #endregion

        NwindDataSet dataSet = new NwindDataSet();

        public PivotTableDemo()
        {
            InitializeComponent();
                  try
            {
                InvoicesTableAdapter adapter = new InvoicesTableAdapter();
                adapter.Fill(dataSet.Invoices);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }

            DataTable tbl = this.dataSet.Invoices;

            UpdateDataSource(tbl);
        }
    
        private void UpdateDataSource(DataTable tbl)
        {
            this.dataGrid1.ItemsSource = tbl.DefaultView;
      
            this.dataGrid1.ColumnsHierarchy.AutoResize();
            this.dataGrid1.RowsHierarchy.AutoResize();     
        }
    
        public void SetTheme()
        {
            dataGrid1.FontFamily = new FontFamily("Tahoma");
        }
  
    } // class CellEditing


}
